package svc

import (
	"github.com/go-redis/redis/v8"
	"github.com/vueadmin/app/api/internal/config"
	"github.com/vueadmin/initialize"
	"go.uber.org/zap"
	"gorm.io/gorm"
)

type ServiceContext struct {
	Config config.Config
	Db     *gorm.DB
	Redis  *redis.Client
	Log    *zap.SugaredLogger
}

func NewServiceContext(c config.Config) *ServiceContext {
	log := initialize.MuestNewLog()
	return &ServiceContext{
		Config: c,
		Log:    log,
		Db:     initialize.MustNewMysql(c.Mysql.DataSource, log),
		Redis:  initialize.MustNewRedis(c.Redis.Host, c.Redis.Password, c.Redis.Db),
	}
}
